package flymoke.reflect;

import java.lang.reflect.Constructor;

public class ReflectDemon4 {
	public static void main(String[] args) {
		Class<?> cla = null;
		Person person = null;
		Person person1 = null;
		Person person2 = null;
		Person person3 = null;
		
		try{
			cla = Class.forName("flymoke.reflect.Person");
		}catch(ClassNotFoundException e){
			e.printStackTrace();
		}
		
		Constructor<?> cons[] = cla.getConstructors();
		int count=0;
		for (Constructor<?> constructor : cons) {
			System.out.println("constructor"+count+":"+constructor);
			count++;
		}
		try{
			person  = (Person)cons[3].newInstance();
			person1 = (Person)cons[0].newInstance(10);
			person2 = (Person)cons[1].newInstance("jack");
			person3 = (Person)cons[2].newInstance(20,"marry");
		}catch(Exception e){
			e.printStackTrace();
		}
		
		System.out.println(person);
		System.out.println(person1);
		System.out.println(person2);
		System.out.println(person3);
	}
}
